//package developer.zyk.global.upload.upload;
//
//import cn.hutool.core.collection.CollUtil;
//import developer.zyk.global.common.consts.OssPlatformEnum;
//import developer.zyk.global.upload.upload.handlers.DoUploadRequest;
//import developer.zyk.global.upload.upload.handlers.UploadHandlerResult;
//import developer.zyk.global.upload.upload.handlers.UploadService;
//import developer.zyk.global.config.UploadProperties;
//import developer.zyk.global.upload.dao.entity.ChatObjectRepositoryDO;
//import developer.zyk.global.upload.dao.mappers.ChatObjectRepositoryMapper;
//import jakarta.annotation.Resource;
//import org.springframework.stereotype.Component;
//
//import java.io.File;
//import java.io.IOException;
//import java.io.InputStream;
//import java.time.LocalDateTime;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//
///**
// * @author zhangyongkang
// * @time 2025/5/14 14:44
// * @description
// */
//@Component
//public class UploadClient {
//
////    @Resource
////    private Map<OssPlatformEnum, UploadService> uploadServiceMap;
////    @Resource
////    private UploadProperties uploadProperties;
////    @Resource
////    private ChatObjectRepositoryMapper chatObjectRepositoryMapper;
////
////    public DoUploadResult doUpload(InputStream inputStream, String fileName, String path) {
////        try (inputStream) {
////            UploadService uploadService = uploadServiceMap.get(OssPlatformEnum.queryByCode(uploadProperties.getPlatFrom()));
////            UploadHandlerResult uploadHandlerResult = uploadService.singleUploadStream(
////                    DoUploadRequest.builder()
////                            .fileName(fileName)
////                            .path(path)
////                            .build(),
////                    inputStream
////            );
////            ChatObjectRepositoryDO chatObjectRepositoryDO = convertResult2DO(uploadHandlerResult, fileName);
////            chatObjectRepositoryMapper.insert(chatObjectRepositoryDO);
////            DoUploadResult doUploadResult = new DoUploadResult();
////            doUploadResult.setId(chatObjectRepositoryDO.getId());
////            doUploadResult.setUrl(uploadHandlerResult.getUrl());
////            return doUploadResult;
////        } catch (IOException e) {
////            throw new RuntimeException(e);
////        }
////    }
////
////    public File download(Long fileId) {
////        return uploadServiceMap.get(OssPlatformEnum.queryByCode(uploadProperties.getPlatFrom()))
////                .download(fileId);
////    }
////
////    private ChatObjectRepositoryDO convertResult2DO(UploadHandlerResult uploadHandlerResult, String fileName) {
////        String fileType = fileName.substring(Math.max(fileName.lastIndexOf("."), 0));
////
////        OssPlatformEnum ossPlatformEnum = OssPlatformEnum.queryByCode(uploadProperties.getPlatFrom());
////        ChatObjectRepositoryDO repositoryDO = new ChatObjectRepositoryDO();
////        repositoryDO.setFileName(fileName);
////        repositoryDO.setBucketName(uploadHandlerResult.getBucketName());
////        repositoryDO.setFileType(fileType);
////        repositoryDO.setUrl(uploadHandlerResult.getUrl());
////        repositoryDO.setPath(uploadHandlerResult.getPath());
////        repositoryDO.setHost(uploadHandlerResult.getHost());
////        repositoryDO.setPlatformOutId(uploadHandlerResult.getPlatFormId());
////        if (Objects.nonNull(ossPlatformEnum)) {
////            repositoryDO.setPlatformCode(ossPlatformEnum.getCode());
////            repositoryDO.setPlatformName(ossPlatformEnum.getName());
////        }
////        repositoryDO.setExtension("");
////        repositoryDO.setCreateTime(LocalDateTime.now());
////        repositoryDO.setCreateBy("");
////        return repositoryDO;
////    }
////
////    public List<ChatObjectRepositoryDO> getFileInfoByIds(List<Long> ids) {
////        if (CollUtil.isEmpty(ids)) {
////            return new ArrayList<>();
////        }
////        return chatObjectRepositoryMapper.selectByIds(ids);
////    }
////
////    public ChatObjectRepositoryDO getFileByFileId(Long id) {
////        return chatObjectRepositoryMapper.selectById(id);
////    }
//}
